#include <bits/stdc++.h>
using namespace std;
int N;
const int maxn = 1e5 + 7;
pair<int, int> P[maxn];
int a[maxn], b[maxn];
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> P[i].second >> P[i].first;
  }
  sort(P, P + N);
  for (int i = 0; i < N; ++i) {
    a[i] = P[i].second;
    b[i] = P[i].first;
    // cout << a[i] << ' ' << b[i] << endl;
  }
  int right = b[0];
  int idx = 0;
  int cnt = 1;
  while (idx < N) {
    while (idx < N && right >= a[idx]) {
      idx++;
    }
    if (idx == N) {
      break;
    } else {
      right = b[idx];
      cnt++;
    }
  }
  cout << cnt << endl;
}
